<?php
        define("GRID_SOURCE", "");       
        include(GRID_SOURCE."class/gridclasses.php"); //Include the grid engine.
        
        session_start();
        require_once "../funciones.php";
        if($_REQUEST[bandera] == 1)
        {
            $link_mantis = con_caweb();
	        $result ="SELECT name FROM clientes WHERE nit = '$_REQUEST[clienteorigen]' ";
	 	    $result=mysql_query($result,$link_mantis) or die('Error clientes, '.mysql_error());
            $row = mysql_fetch_array($result);
            $_SESSION['caweb']['nombreorigen'] = substr($row[name],0,25);
            
            $result ="SELECT name FROM clientes WHERE nit = '$_REQUEST[clientedestino]' ";
	 	    $result=mysql_query($result,$link_mantis) or die('Error clientes, '.mysql_error());
            $row = mysql_fetch_array($result);
            $_SESSION['caweb']['nombredestino'] = substr($row[name],0,25);            
            
            $_SESSION['caweb']['clienteorigen'] = $_REQUEST[clienteorigen];
            $_SESSION['caweb']['clientedestino'] = $_REQUEST[clientedestino];
            $_SESSION['caweb']['sucursalfactura'] = $_REQUEST[sucursalfactura];
            $_SESSION['bandera'] = $_REQUEST[bandera];
        }        
        $grid_id = array("grid");
        unset($_SESSION["grid"]);
        include(GRID_SOURCE."class/gridcreate.php"); //Creates grid objects.
?>
<html>
        <head>
                <title>Reubicacion de equipos entre Clientes </title>
                <script language="Javascript" type="text/javascript" src="<?php print(GRID_SOURCE);?>javascript/javascript.js"></script>
                <link href="<?php print(GRID_SOURCE);?>css/style.css" rel="stylesheet" type="text/css" />
				<script type='text/javascript' src="<?php print(GRID_SOURCE);?>server.php?client=all"></script>
				<script>
				HTML_AJAX.defaultServerUrl = '<?php print(GRID_SOURCE);?>server.php';
				</script>
		<script src="jquery.js"></script>
        <script>
        function validar(e,serial)
        {
            var tecla;
	
            if (document.all) { tecla = e.keyCode;  } 
            else {  tecla = e.which; }
            if (tecla == 13) { location.href="adiciona_ruc.php?serial="+serial;  }
            else { return false; }
        }
        </script>
        </head>
        <body onload="document.getElementById('Editbox1').focus();">
		Interno :<input type="text" id="Editbox1" onkeypress="validar(event,this.value);" size="15" name="Editbox1" value="" />
        <?php

			$transaccion=$_SESSION['caweb']['consecutivo'];
			echo  "Ultimo Interno ".$_SESSION['caweb']['ultimointerno'];
			if ($_SESSION['caweb']['resultado'] == 0) { echo "<font color=red><b> NO EXISTENTE </b></font>"; }
		 	if ($_SESSION['caweb']['resultado'] == 1) { echo "<font color=green><b> CORRECTO </b></font>"; }
            if ($_SESSION['caweb']['resultado'] == 2) { echo "<font color=orange><b> INTERNO EN TRANSACCION $transaccion </b></font>"; }
            if ($_SESSION['caweb']['resultado'] == 3) { echo "<font color=red><b> Error, INTERNO NO esta en bodega cliente </b></font>"; }
            if ($_SESSION['caweb']['resultado'] == 4) { echo "<font color=red><b> Error, INTERNO con calidad NO Conforme </b></font>"; }
            if ($_SESSION['caweb']['resultado'] == 5) { echo "<font color=red><b> Error, INTERNO con estado NO Vigente </b></font>"; }
            if ($_SESSION['caweb']['resultado'] == 6) { echo "<font color=red><b> Error, INTERNO NO esta en Cliente Origen </b></font>"; }
            
			$condicion="transaccion='$transaccion'";
   			$_SESSION["grid"]->SetDatabaseConnection($_SESSION['caweb']['basededatos'], "caweb", "caweb");
           	$_SESSION["grid"]->SetSqlSelect('id, interno, item, cantidad, sucursalfactura, origen, destino ', 'temporal', $condicion);
			$_SESSION["grid"]->SetUniqueDatabaseColumn("id", false);
			$_SESSION["grid"]->SetTitleName("(Transaccion: $transaccion) - Internos en cliente origen ");
			$_SESSION["grid"]->SetEditModeEdit(false);
			$_SESSION["grid"]->SetMaxRowsEachPage(20);
            $_SESSION["grid"]->SetDatabaseColumnEditable("id", false);
			$_SESSION["grid"]->SetDatabaseColumnEditable("interno", false);
   	        $_SESSION["grid"]->SetDatabaseColumnEditable("item", false);
            $_SESSION["grid"]->SetDatabaseColumnEditable("cantidad", false);
            $_SESSION["grid"]->SetDatabaseColumnEditable("sucursalfactura", false);
            $_SESSION["grid"]->SetDatabaseColumnEditable("origen", false);
   	        $_SESSION["grid"]->SetDatabaseColumnEditable("destino", false);
			$_SESSION["grid"]->SetShowExcelIco(false);
			$_SESSION["grid"]->SetShowPrintIco(false);
			$_SESSION["grid"]->PrintGrid(MODE_EDIT);
        ?>
        </body> 
</html>